package com.example.musicdemo.util

import com.example.musicdemo.R
import com.example.musicdemo.base.BaseFragment
import com.example.musicdemo.ui.fragment.HomeFragment
import com.example.musicdemo.ui.fragment.MvFragment
import com.example.musicdemo.ui.fragment.VBangFragment
import com.example.musicdemo.ui.fragment.YueDanFragment

class FragmentUtil private constructor() {
    private val homeFragment by lazy { HomeFragment() }
    private val mvFragment by lazy { MvFragment() }
    private val vBangFragment by lazy { VBangFragment() }
    private val yueDanFragment by lazy { YueDanFragment() }

    companion object {
        val fragmentUtil by lazy { FragmentUtil() }
    }


    /**
     * 根据tabId获取不同的碎片
     */
    fun getFragment(tabId: Int): BaseFragment? {
        when (tabId) {
            R.id.rl_home -> return homeFragment
            R.id.rl_mv -> {
                println("我来过马")
                return mvFragment}
            R.id.rl_ybang -> return vBangFragment
            R.id.rl_yuedan -> return yueDanFragment
        }
        return null
    }

}